package sys.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import sys.core.annotation.LoginRequired;
import sys.core.annotation.RecordLog;
import sys.entity.MenuEntity;
import sys.entity.PageData;
import sys.service.MenuService;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/menu")
@Api(tags = "菜单管理")
public class MenuController {




    @Autowired
    private MenuService menuService;


    /**
     * 查询
     *
     * @return
     */
    @ApiOperation(value = "查询")
    @LoginRequired
    @RecordLog
    @PostMapping(value = "/select")
    public List<MenuEntity> select(@RequestBody MenuEntity MenuEntity) {
        return menuService.select(MenuEntity);
    }
    @PostMapping(value = "/selectAll")
    public List<MenuEntity> selectAll() {
        return menuService.select(null);
    }
    /**X
     * 模糊查询
     *
     * @returnW
     */
    @ApiOperation(value = "模糊查询")
    @LoginRequired
    @RecordLog
    @PostMapping(value = "/likeSelect")
    public PageData<MenuEntity> likeSelect(@RequestBody MenuEntity MenuEntity) {
        return menuService.likeSelect(MenuEntity);
    }
    /**
     * 更新
     *
     * @return
     */
    @ApiOperation(value = "更新")
    @LoginRequired
    @RecordLog
    @PostMapping(value = "/update")
    public void update(@RequestBody MenuEntity entity) {
        menuService.update(entity);
    }

    /**
     * 添加
     *
     * @return
     */
    @ApiOperation(value = "添加")
    @LoginRequired
    @RecordLog
    @PostMapping(value = "/add")
    public void add(@RequestBody MenuEntity entity) {
        menuService.add(entity);
    }

    /**
     * 删除
     *
     * @return
     */
    @ApiOperation(value = "删除")
    @LoginRequired
    @RecordLog
    @PostMapping(value = "/delete")
    public void delete(@RequestBody MenuEntity entity) {
        menuService.delete(entity);
    }

    /**
     * 导出excel
     *
     * @return
     */
    @ApiOperation(value = "导出excel")
    @LoginRequired
    @RecordLog
    @GetMapping("/exportExcel")
    public void exportExcel(MenuEntity entity, HttpServletResponse response) {
        menuService.exportExcel(entity, response);
    }

}
